// Copyright (c) 2024, the Dart project authors.
// All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:meta/meta.dart' show internal;

import '../arkobject.dart' hide ArkObject;
import '../arkreference.dart';
import '../types.dart';

// Simple ArkByteBuffer implementation
class ArkByteBuffer {
  final List<int> data;
  
  ArkByteBuffer(this.data);
  
  ArkByteBuffer.fromReference(ArkReference reference) : data = []; // TODO: implement
  
  static const type = ArkByteBufferType();
  static const nullableType = ArkByteBufferNullableType();

  static final _class = ArkClass.forName(r'ark/nio/ByteBuffer');
  static final _ctorId = _class.constructorId(r'(I)V');
  
  ArkByteBuffer.byteBufferCtor(int capacity) : data = List.filled(capacity, 0);

  static final _capacityId =
      _class.instanceMethodId(r'capacity', r'()I');
  static final _positionId =
      _class.instanceMethodId(r'position', r'()I');
  static final _limitId =
      _class.instanceMethodId(r'limit', r'()I');

  int capacity({bool releaseOriginal = false}) {
    // TODO: implement actual method call
    return data.length;
  }
  
  int position({bool releaseOriginal = false}) {
    // TODO: implement actual method call
    return 0;
  }
  
  int limit({bool releaseOriginal = false}) {
    // TODO: implement actual method call
    return data.length;
  }
  
  @override
  String toString() => 'ArkByteBuffer(${data.length} bytes)';
}

// Simple type definitions
class ArkByteBufferType {
  const ArkByteBufferType();
}

class ArkByteBufferNullableType {
  const ArkByteBufferNullableType();
}

